package com.gim.util;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import java.nio.charset.StandardCharsets;

public class AcceptDataClient extends SimpleChannelInboundHandler<ByteBuf> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
        byte[] data = new byte[msg.readableBytes()];
        msg.readBytes(data);

        // 直接转换为字符串并打印
        String receivedString = new String(data, StandardCharsets.UTF_8);
        System.out.println("Received data as string: " + receivedString);
    }
}
